package com.zlf.sb.demo.service.impl;

import com.zlf.sb.demo.entity.UserEntity;
import com.zlf.sb.demo.inquery.ResultHandler;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

/***
 *@title PersonInResultHandler
 *@description <TODO description class purpose>
 *@author wgc_j
 *@version 1.0.0
 *@create 2025-03-07 14:26
 **/
@Component("personResultHandler")
public class PersonInResultHandler implements ResultHandler<List<UserEntity>> {
    @Override
    public List<UserEntity> process(List<Object> result) {
        if (result == null) {
            return null ;
        }
        return result.stream()
                // 这里我们知道返回的类型，所有可以直接进行类型的转换
                .flatMap(obj -> ((List<UserEntity>)obj).stream())
                .collect(Collectors.toList()) ;
    }
}